package com.bw.module_home.device.adapter

import android.graphics.Color
import com.bw.module_home.R
import com.bw.module_home.device.model.DeviceEntityItem
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class DeviceAdapter:BaseQuickAdapter<DeviceEntityItem, BaseViewHolder>(R.layout.layout_device_item) {
    override fun convert(holder: BaseViewHolder, item: DeviceEntityItem) {
        holder.setText(R.id.device_name,"项目名称/设备名称:"+item.deviceName)
        holder.setText(R.id.device_type,"设备类型:"+item.deviceType)
        holder.setText(R.id.device_address,"安装地点:"+item.installationLocation)
        holder.setText(R.id.device_lv,"故障率:"+item.failureRate*100+"%")
        holder.setText(R.id.device_status,""+item.status)
        when(item.status){
            "故障"->{
                holder.setBackgroundResource(R.id.device_status,R.drawable.shape_device_item2)
                holder.setTextColor(R.id.device_status,Color.parseColor("#FA8123"))
            }
            "正常"->{
                holder.setBackgroundResource(R.id.device_status,R.drawable.shape_device_item1)
                holder.setTextColor(R.id.device_status,Color.parseColor("#3EC871"))
            }
        }
    }
}